package com.song.service.bug;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.song.common.Result;
import com.song.dao.bug.BugDao;
import com.song.dao.menu.MenuDao;
import com.song.entity.bug.Bug;
import com.song.entity.menu.Menu;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service("bugService")
public class BugServiceImpl extends ServiceImpl<BugDao,Bug> implements BugService {

    @Autowired
    private BugDao bugDao;

    @Override
    public Result<List<Bug>> selectBugList(Bug bug, String startTime, String endTime, int pageNum, int pageSize) {
        Result<List<Bug>> result = new Result<>();
        PageHelper.startPage(pageNum,pageSize);

        Map<String,Object> map = new HashMap<>();
        map.put("bugTitle",bug.getBugTitle());
        map.put("startTime",startTime);
        map.put("endTime",endTime);
        map.put("bugStatus",bug.getBugStatus());

        List<Bug> bugList = bugDao.selectBugList(map);
        PageInfo<Bug> pageInfo = new PageInfo<>(bugList);
        result.setCode(0);
        result.setCount((int)pageInfo.getTotal());
        result.setData(bugList);
        return result;
    }
}
